import axios from "axios";
import qs from 'qs';
import store from "../store";
const ajaxHeader = {
    headers: {
      "Content-Type": "application/json"
    }
  }
//订阅课程
export const  subscribeCourse = (courseId) =>axios.post(`/h5live/course/subscribeCourse`,qs.stringify({courseId}))
//取消订阅课程
export const  cancelSubscribeCourse = (courseId) =>axios.post(`/h5live/course/cancelSubscribeCourse `,qs.stringify({courseId}))
//付费课程收藏
export const  courseCollect = (courseId,status) =>axios.post(`/h5live/course/scCourse`,qs.stringify({courseId,status}))
//打点 
// sessionId, //场次id
// streamType, //视频类型：1-预告 2-直播 3-回看 10-全局统计 11-商品点击 12-页面
// actionValue, //行为：1-进入 2-离开 3-点击播放 4-留言 5-点赞 6-关注 7-分享 8-开播 9-关播 10-最高峰值
// playSource: this.getPlatform(), //微信 app
// url: window.location.href, //当前的url
export const  dotNum = (sessionId,streamType=12,actionValue = 1,playSource = fun.getPlatform(),url= window.location.href)=> axios.post(`/h5live/recordData`,{sessionId,streamType,actionValue ,playSource,url},ajaxHeader)
//商品信息  //mixId 房间id或回看id   type 0-直播间,1-回看
export const  shoppingInfo = (mixId,type)=> axios.get(`/h5live/getRoomGoodsAndTitle/v2?mixId=${mixId}&type=${type}&plat=${fun.getPlatform()}`)
//购物车风险提示 mixId 房间id或回看id   type 0-直播间,1-回看
export const  shoppingRiskTip  = (mixId,type) => axios.get(`/h5live/getGoodsWinTip?mixId=${mixId}&type=${type}`)
//购物车是否授权 mixId 房间id或回看id   type 0-直播间,1-回看  直播间维度
export const  isCheckUserAuthShoppingPop  = (mixId,type) => axios.get(`/h5live/checkUserAuthPopWinTip?mixId=${mixId}&type=${type}`)
//购物风险提示确认按钮
export const  userCheckClickGoodsRiskTip  = (mixId,type,check,i) => axios.get(`/h5live/userClickGoodsWinTip?mixId=${mixId}&type=${type}&enCheck=${check}&enAgree=${i}`)
//直播间人数限制
export const checkLiveMaxUvLimit = (roomId) =>axios.post(`/h5live/room/checkUvLimit`,qs.stringify({roomId}))
//params = {} ==>
//'id': goods:{商品ID}:{type,1-直播,2-回看}:{roomId/videoId},
//'plat': fun.getPlatform()
export const shoppingDotNum  = (params) => axios.post(`/h5live/goodsClick`,qs.stringify(params));
//首页
// //1.首页直播预告列表
// export const  homeLivePreList = ()=> axios.get(`/h5live/getRoomList`)
// //2 设置提醒状态
// export const  postRemindData = (roomId,isRemind)=> axios.post(`/h5live/setZbRemind`,qs.stringify({roomId,isRemind}))
// //中信信用卡首页活动位置获取功能区 plat 1是app 2是微信
// export const  getMiddleIconData = (plat)=> axios.get(`/h5live/hzb/home/getFixedFunction?plat=${plat}&page=1&pageSize=10`)
// //中信信用卡积分发言
// export const  sendMsgIntegral = (roomId,anchor,giftId,message)=> axios.get(`/zb/live/speakFloatScreen?roomId=${roomId}&anchor=${anchor}&giftId=${giftId}&clickTimes=1&num=1&lts=1&message=${message}`)
// //中信信用卡积分发言
// //查询直播间抽奖邀请榜单是否结束
// export const  shareInviteFinishLiveApi =(roomId)=> axios.get(`/h5live/shareInviteFinish?roomId=${roomId}`)
// //查询回看邀请榜单是否结束
// export const  shareInviteFinishBackApi =(vid)=> axios.get(`/h5live/vod/shareInviteFinish?vid==${vid}`)
// //礼物列表查询  type 1-礼物，2-弹幕
// export const  getGiftListRoomData = (roomId,type)=> axios.get(`/zb/live/getGiftList?roomId=${roomId}&type=${type}`)
// //送礼
// export const  sendGiftPort = (roomId,anchor,giftId,clickTimes)=> axios.get(`/zb/live/userRewardGift?roomId=${roomId}&anchor=${anchor}&giftId=${giftId}&clickTimes=${clickTimes}`)
// //打赏列表
// export const  rewardListApi = (page,pageSize = 10,lastId)=> axios.get(`/zb/live/userRewardRecordList?page=${page}&pageSize=${pageSize}&lastId=${lastId}`)
// //打点 
// // sessionId, //场次id
// // streamType, //视频类型：1-预告 2-直播 3-回看 10-全局统计 11-商品点击 12-页面
// // actionValue, //行为：1-进入 2-离开 3-点击播放 4-留言 5-点赞 6-关注 7-分享 8-开播 9-关播 10-最高峰值
// // playSource: this.getPlatform(), //微信 app
// // url: window.location.href, //当前的url
// export const  dotNum = (sessionId,streamType=12,actionValue = 1,playSource = fun.getPlatform(),url= window.location.href)=> axios.post(`/h5live/recordData`,{sessionId,streamType,actionValue ,playSource,url},ajaxHeader)
// // 查询是否手机验证
// // export const reqIsSmsAuth = data => axios({
// //   url: `/h5live/sms/hadMobile`,
// //   method: 'POST',
// //   data,
// //   headers: { "Content-Type": "application/json" },
// // });
// //mixId: roomId,   房间id
// //type: mode  房间模式  //mixId 房间id或回看id   type 0-直播间,1-回看
// export const  postMobileVer = (mixId,type)=> axios.post(`/h5live/sms/hadMobile`,{mixId,type},ajaxHeader)
// 账号注销 查询
export const cancelQuery = () => axios.get(`/user/cancelQuery`)
// 账号注销
export const cancel = () => axios.post(`/user/cancel`,{})
// 注销撤回
export const cancelWithdraw = () => axios.post(`/user/cancelWithdraw`,{})
//回看留言
export const getBackMessageApi = (videoId,page) =>axios.get(`/h5live/getComment?vid=${videoId}&page=${page}`)
//特色频道
export const getTspdVideos = (params) => axios.get(`/h5live/getTspdVideos`,{params})
//专辑专辑类型tspdType 默认1 1专辑 2小视频 3 视频推荐
export const getCategory = (menuId,tspdType) => axios.get(`/h5live/zx/fc/category?menuId=${menuId}&tspdType=${tspdType}`)
//专辑菜单
export const getTsMenu = () => axios.get(`/h5live/zx/fc/menu`,{})
//精彩视频
export const getGreadVideo = (params) => axios.get(`/h5live/getHomeVideo`,{params})
//查询是否关注
export const getIsAttentionFun = (anchor) => axios.get(`/h5live/checkIsFollow?anchorAcct=${anchor}`)
//关注
export const setLiveAttentionFun = (anchor) => axios.post(`/h5live/mini/followAnchor/${anchor}`)
//取消关注
export const removeLiveAttentionFun = (anchor) => axios.post(`/h5live/mini/cancelFollowAnchor/${anchor}`)
//分享打点
export const shareDotNum = (params)=>axios.post(`/h5live/shareStatic`,params,ajaxHeader)

// 视频专区
// 查询是否关注机构/订阅专栏/收藏视频/收藏直播间/点赞视频  businessId   businessType 1-关注机构 2-订阅专栏 3-收藏视频  4-收藏直播间 5-点赞视频 6-直播小站机构
export const getFollowState = (businessId, businessType) => axios.post(`/h5live/videoZone/checkIsFollow?businessId=${businessId}&businessType=${businessType}`)

//点击订阅 专栏/机构   businessId   机构号/专栏Id   businessType   1-关注机构 2-订阅专栏 6-关注机构(直播小站)
export const followSpecialColumn = (businessId, businessType) => axios.post(`/h5live/videoZone/follow?businessId=${businessId}&businessType=${businessType}`)

//点击取消订阅 专栏/机构    businessId   机构号/专栏Id   businessType   1-关注机构 2-订阅专栏 6-关注机构(直播小站)
export const cancelFollowSpecialColumn = (businessId, businessType) => axios.post(`/h5live/videoZone/cancelFollow?businessId=${businessId}&businessType=${businessType}`)

//查询物料所属专栏  
export const getColumn = (data) => axios.post(`/h5live/videoZone/columnList`, data, ajaxHeader)

//获取我的收藏列表   type:类型 1-视频收藏 2-直播间收藏
export const getCollectList = (type,page,pageSize) => axios.post(`/h5live/videoZone/getCollectList?type=${type}&page=${page}&pageSize=${pageSize}`)

//获取订阅专栏列表
export const getFollowColumnList = (page, pageSize) => axios.post(`/h5live/videoZone/getFollowColumnList?page=${page}&pageSize=${pageSize}`)

//获取关注的机构的列表
export const getFollowInstitutionList = (businessType, page, pageSize) => axios.post(`/h5live/videoZone/getFollowInstitutionList?businessType=${businessType}&page=${page}&pageSize=${pageSize}`)

//查询视频点赞数
export const queryLikeCount = (videoId, channel) => axios.get(`/h5live/videoZone/video/likeCount?videoId=${videoId}&channel=${channel}`)

// 收藏视频/收藏直播间/点赞视频  3-收藏视频 4-收藏直播间 5-点赞视频
export const collectOrLike = (businessId, businessType, channel) => axios.post(`/h5live/videoZone/video/collectOrLike?businessId=${businessId}&businessType=${businessType}&channel=${channel}`)

// 取消 收藏视频/收藏直播间/点赞视频  3-收藏视频 4-收藏直播间 5-点赞视频
export const cancelCollectOrLike = (businessId, businessType, channel) => axios.post(`/h5live/videoZone/video/cancelCollectOrLike?businessId=${businessId}&businessType=${businessType}&channel=${channel}`)

// 查询视频所属专栏
export const queryColumnList = (data) => axios.post(`/h5live/videoZone/columnList`, {body: data}, ajaxHeader)


//推荐位详情
export const getRecommendData = (data) => axios.post('/h5live/videoZone/wealthList', data, ajaxHeader)

//查询一级与二级栏目信息
export const getColumnTabs = (data) => axios.post('/h5live/videoZone/getColumnTabs', data, ajaxHeader)

//获取热门标签
export const getHotSearchTags = () => axios.get('/h5live/videoZone/getHotSearchTags')

//获取搜索内容
export const getSearchContent = (data) => axios.post('/h5live/videoZone/searchContentByTitleOrTag', data, ajaxHeader)

//根据机构code查询对应机构的内容（非直播小站）{ "contentType": 0, "institutionCode": "string" , "pageNumber": 0 , "pageSize": 0 }
export const getInstitutionContent = (data) => axios.post('/h5live/videoZone/queryContentByInstitutionCode', data, ajaxHeader)

//根据机构code查询对应机构的内容（直播小站）
export const getInstitutionContentLiveState = (tagId, type, acct, page, pageSize) => axios.post(`/h5live/videoZone/getVideoListByAcct?tagId=${tagId}&type=${type}&acct=${acct}&page=${page}&pageSize=${pageSize}`, ajaxHeader)

//根据机构code查询机构信息 {"institutionId": "string"}
export const getInstitutionInfo = (data) => axios.post('/h5live/videoZone/getInstitutionInfoByCode', data, ajaxHeader)

//根据机构code查询机构信息(直播小站) 
export const getInstitutionLiveStateInfo = (acct) => axios.post(`/h5live/videoZone/getInstitutionInfoByAcct?acct=${acct}`, ajaxHeader)

//一级菜单的精选中的收藏最多
export const getVideoCollectMost = (page,pageSize) => axios.get(`/h5live/videoZone/getVideoCollectMost?page=${page}&pageSize=${pageSize}`, ajaxHeader)

//一级菜单的精选中的观看最多
export const getVideoWatchMost = (page, pageSize) => axios.get(`/h5live/videoZone/getVideoWatchMost?page=${page}&pageSize=${pageSize}`, ajaxHeader) 

//直播小站
export const getLiveStation = (type, tagId, page, pageSize) => axios.get(`/h5live/videoZone/getLiveStation?type=${type}&tagId=${tagId}&page=${page}&pageSize=${pageSize}`, ajaxHeader) 
//banner   //useType 1 是 首页    2 专辑管理
export const  getAdlist =(useType)=> axios.get(`/h5live/zx/home/adlist?useType=${useType}`)
//新版白名单
export const checkWhitelist = (params)=>axios.post(`/whitelist/validate`,params,ajaxHeader);
//新版白名单库
export const NewCheckWhitelist = (params)=>axios.post(`/whitelist/validate2`,params,ajaxHeader);